package xiao.trip.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import xiao.trip.Do.helpDO;
import xiao.trip.dao.UserDAOByXML;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
public class helpController {

    @Autowired
    UserDAOByXML userDAOByXML;

    @RequestMapping("/toaddhelp")
    public String toaddhelp() {
        return "moneyhelp/addhelp";

    }

   /* @RequestMapping("/toaddclub")
    public String toaddclub() {
        return "club/addclubactivity";
    }*/

    @RequestMapping("/helpindex")
    public String getUserList(Model model) {
        List<helpDO> moneyhelplist = userDAOByXML.selectAllmoneyhelp();
        model.addAttribute("moneyhelplist", moneyhelplist);
        return "moneyhelp/helpindex";
    }

    @RequestMapping("/addmoneyhelp")
    public String addhelp(HttpServletRequest Request, Map map) {
        String moneyhelp = Request.getParameter("moneyhelp");
        String money = Request.getParameter("money");
        String starttime = Request.getParameter("starttime");
        String endtime = Request.getParameter("endtime");
        String telephone = Request.getParameter("telephone");
        if (userDAOByXML.insertmonethelp(moneyhelp, money, starttime, endtime, telephone) != null) {
            map.put("insertright", ("插入成功"));
            return "forward:helpindex";
        } else {
            map.put("inserterror", ("插入失败"));
            return ("forward:helpindex");
        }
    }
}
   /* @RequestMapping("/toclub")
    public String getclublist(HttpServletRequest Request, Model model){
        List<clubDO> clublist = userDAOByXML.selectAllclub();
        System.out.println(clublist);
        model.addAttribute("clublist",clublist);
        return ("club/club");
    }

    @RequestMapping("/addclubactivity")
    public String se(HttpServletRequest Request, Map map){
        String clubname =Request.getParameter("clubname");
        String clubactivity =Request.getParameter("clubactivity");
        if (userDAOByXML.insertclubactivity(clubname,clubactivity)!=null){
            map.put("insertright",("插入成功"));
            return "forward:toclub";
        }
        else{
            map.put("inserterror",("插入失败"));
            return "forward:toclub";
        }
    }
}*/
